package com.ac.cv.server.data;

import java.util.ArrayList;
import java.util.List;

import com.ac.cv.client.service.MenuItemDataClient;
import com.ac.cv.client.service.MenuMainItemDataClient;

public class ClientToServer {

	
	
	public static MenuMainItemData getMainFromClient(MenuMainItemDataClient clientData){
		MenuMainItemData result = new MenuMainItemData();
		result.setTitle(clientData.getTitle());
		result.setName(clientData.getName());
		List<MenuItemData> itemList = new ArrayList<MenuItemData>();
		for(MenuItemDataClient item : clientData.getItemList()){
			MenuItemData itemServer =getMainFromClient(item);
			itemServer.setParent(result);
			itemList.add(itemServer);			
		}
		result.setItemList(itemList);
		
		return result;
	}
	
	public static MenuMainItemDataClient getMainFromServer(MenuMainItemData serverData){
		MenuMainItemDataClient result = new MenuMainItemDataClient();
		List<MenuItemDataClient> itemList = new ArrayList<MenuItemDataClient>();
		for(MenuItemData item : serverData.getItemList()){
			MenuItemDataClient itemClient = getMainFromServer(item);
			itemClient.setParent(result);
			itemList.add(itemClient);
		}
		result.setItemList(itemList);
		result.setTitle(serverData.getTitle());
		result.setName(serverData.getName());
		return result;
	}
	
	public static MenuItemData getMainFromClient(MenuItemDataClient dataClient){
		MenuItemData result = new MenuItemData();
		result.setContent(dataClient.getContent());
		result.setTitle(dataClient.getContent());
		result.setName(dataClient.getName());
		return result;
		
	}
	
	public static MenuItemDataClient getMainFromServer(MenuItemData dataClient){
		MenuItemDataClient result = new MenuItemDataClient();
		result.setContent(dataClient.getContent());
		result.setTitle(dataClient.getTitle());
		result.setName(dataClient.getName());
		return result;
	}
	
}
